﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using lgweb.common;
using LGCourt.Logic.BLL;
using LGCourt.Logic.NBL.DBEntities;

namespace lgweb.inside.department
{
    public partial class deptinfo : NeedValidatePage
    {
        private int _aid = 1;
        public string _cate = "0";
        public string _DeptID = "0";
        public string _ClassID = "0";
        public string _picUrl = "";
        public string _DetpName = "";
        private string type = "1";
        protected new void Page_Load(object sender, EventArgs e)
        {
            base.Page_Load(sender, e);
            if (!this.IsPostBack)
            {
                _picUrl = System.Configuration.ConfigurationManager.AppSettings["InfoManage"];
                _picUrl = string.IsNullOrEmpty(_picUrl) ? "/lgmanage/Systems/upload/" : _picUrl;
                GetParam();
                GetDeptInfo();
            }
        }

        private void GetParam()
        {
            this._aid = string.IsNullOrEmpty(Request.QueryString["id"]) ? 1 : Convert.ToInt32(Request.QueryString["id"]);
            this._DeptID = string.IsNullOrEmpty(Request.QueryString["deptid"]) ? "0" : Request.QueryString["deptid"].ToString();
            this._ClassID = string.IsNullOrEmpty(Request.QueryString["classid"]) ? "0" : Request.QueryString["classid"].ToString();
            this._cate = string.IsNullOrEmpty(Request.QueryString["cate"]) ? "0" : Request.QueryString["cate"];
            this.type = string.IsNullOrEmpty(Request.QueryString["type"]) ? "1" : Request.QueryString["type"];
        }

        //获取部门信息
        private void GetDeptInfo()
        {
            ColInfo colInfoBLL = new ColInfo();
            DeptClassCondition param = new DeptClassCondition();
            //取部门
            param.Name = "部门";
            param.ClassID = int.Parse(_DeptID);
            V_DICT_SOURCE deptInfo = colInfoBLL.GetDeptSourceInfo(param);
            if (deptInfo == null)
            {
                deptInfo = new V_DICT_SOURCE();
            }
            _DetpName = deptInfo.Source;

            //取栏目
            param.Name = "部门栏目";
            param.ClassID = int.Parse(_ClassID);
            V_DICT_SOURCE classInfo = colInfoBLL.GetDeptSourceInfo(param);
            if (classInfo == null)
            {
                classInfo = new V_DICT_SOURCE();
            }

            DeptCondition deptParam = new DeptCondition();
            deptParam.ClassID = classInfo.ID.GetValueOrDefault(0);
            deptParam.DeptID = deptInfo.ID.GetValueOrDefault(0);
            IF_DeptClass deptClass = colInfoBLL.GetDeptClassInfo(deptParam);

            //部门信息
            deptParam = new DeptCondition();
            deptParam.DeptID = deptInfo.ID.GetValueOrDefault(0);
            LGFY_Platform_Index deptIndex = colInfoBLL.GetDeptIndexInfo(deptParam);
            string stitle="";
            string sdeptinfo="";
            string sdeptinfomore="";
            if (deptIndex != null)
            {
                spInfoEditer.InnerText = deptIndex == null ? "" : deptIndex.Managers;
                switch (type)
                {                    
                    case "1":
                        {
                            stitle = "部门职能";
                            sdeptinfo = deptIndex.FunctionsIndex;
                            sdeptinfomore = deptIndex.Functions;
                        }
                        break;
                    case "2":
                        {
                            stitle = "部门人员及分工";
                            sdeptinfo = deptIndex.StaffIndex;
                            sdeptinfomore = deptIndex.Staff;
                        }
                        break;
                    default:
                        {
                            stitle = "部门职能";
                            sdeptinfo = deptIndex.FunctionsIndex;
                            sdeptinfomore = deptIndex.Functions;
                        }
                        break;
                }
                spNewsName.InnerText = stitle;
                this.hTitle.InnerText = stitle;                
                this.divDeptInfo.InnerHtml = sdeptinfo;
                this.divDeptInfoMore.InnerHtml = sdeptinfomore;
            }
           
        }      
    }
}